-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix C# tool script displaying exported variables in the wrong order #48143
Fix C# tool script displaying exported variables in the wrong order #48143
Conversation
Previously, exported variables in a C# tool script would not appear in the order they were exported within the inspector upon rebuilding the project solution. The potential cause of this problem is that the CSharpInstance::get_property_list method was iterating through the member_info Map member variable to populate the p_properties list argument. Maps typically do not give guarantees about the ordering of elements and I think that Godot's implementation of Map may also shuffle elements around. My proposed solution is to add a new list within the CSharpScript class that contains the keys of the member_info Map in the order they were inserted. This list is cleared and gets new elements whenever the member_info Map is cleared or updated. This fix causes exported variables in C# tools scripts to appear in the order they were exported within the inspector after rebuilding the project solution just like regular C# scripts. Fixes godotengine#47465
Thanks for the contribution :) I'll let @neikeq review the implementation for Mono specifically. Some meta comments:
|
Thanks for the kind words and fast comment! The email tip is much appreciated. |
@devin-liang Any update? There still needs to be a version of this PR for the |
Maybe this should be done similarly to how GDScript does it: godot/modules/gdscript/gdscript.cpp Lines 1429 to 1442 in 6609ce1
|
Closing as this needs to be redone as advised above. Marking as salvageable. |
@neikeq It seems what GDScript does is simply sort the properties by their index which they keep in a different @devin-liang Are you still working on this? If not, would you mind if I give it a try? |
@raulsntos Yeah go ahead and give it try if you'd like. I don't think I'll be actively working on this anymore. I apologize for no updates on this issue for so long. |
Hello all, first time contributor here :)
Previously, exported variables in a C# tool script would not appear in
the order they were exported within the inspector upon rebuilding the
project solution. The potential cause of this problem is that the
CSharpInstance::get_property_list method was iterating through
the member_info Map member variable to populate the p_properties
list argument.
Maps typically do not give guarantees about the ordering of elements
and I think that Godot's implementation of Map may also shuffle elements
around.
My proposed solution is to add a new list within the CSharpScript
class that contains the keys of the member_info Map in the order
they were inserted. This list is cleared and gets new elements
whenever the member_info Map is cleared or updated.
This fix causes exported variables in C# tools scripts to appear
in the order they were exported within the inspector after rebuilding
the project solution just like regular C# scripts.
Fixes #47465